export function GptSlotDiv(html) {
    const result = { ...html };

    for (const key in result) {
        if (key.startsWith('ad') && result[key]) {
            const value = result[key]
            result[key] = getEachslot(value);
        }
    }
    let gptScript = result['htmlTest']
    const interstitial = result.interstitial?.trim() || '';
    const anchor = result.anchor?.trim() || '';
    if (interstitial) gptScript += `\n${interstitial}\n`;
    if (anchor) gptScript += `${anchor}\n`;


    if (gptScript) {
        result.htmlTest = gptScript + (result.htmlTest || '');
    }

    return result;
}

function getEachslot(value) {
    if (value === null) return '';
    return `<div class='gptslot'>
           ${value} 
        </div>`;

}

GptSlotDiv.exampleForm = {
    host: 'www.gptslotdiv.com',
    dirpath: 'example',
    html: {
        htmlTest: ``,
        hd_index: ``,
        hd_details: ``,
        hd_category: ``,
        hd_play: ``,
        ad0_0: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000000"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad0_1: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000001"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad0_2: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000002"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad0_3: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000003"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad0_4: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000004"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad1_0: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000005"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad1_1: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000006"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        ad1_2: `<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-accountCode"
     data-ad-slot="0000000007"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>`,
        interstitial: ``,
        anchor: ``,
    }
}